package com.ydj.app.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ydj.app.entity.WebUser;
import com.ydj.app.protocol.http.web.*;
import com.ydj.app.protocol.http.cms.CmsForecastResultListReq;
import com.ydj.app.protocol.http.cms.CmsForecastResultListRes;
import com.ydj.app.service.ForecastService;
import com.ydj.framework.exception.CommonException;
import com.ydj.framework.protocol.JsonResult;
import com.ydj.app.entity.CmsAccount;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/web/forecast")
@Api(tags = "WEB-预测")
public class WebForecastController {


    @Autowired
    private ForecastService forecastService;

    @ResponseBody
    @ApiOperation(value = "获取问题")
    @ApiOperationSupport(order = 10)
    @PostMapping(value = "/question")
    public JsonResult<WebForecastQuestionRes> list(@RequestBody @Validated WebForecastQuestionReq req, @ApiIgnore WebUser webUser) throws CommonException {
        WebForecastQuestionRes res = forecastService.webQuestion(req, webUser);
        return JsonResult.success(res);
    }

    @ResponseBody
    @ApiOperation(value = "提交问题")
    @ApiOperationSupport(order = 20)
    @PostMapping(value = "/commit")
    public JsonResult<WebForecastCommitRes> commit(@RequestBody @Validated WebForecastCommitReq req, @ApiIgnore WebUser webUser) throws CommonException {
        WebForecastCommitRes res = forecastService.webCommit(req, webUser);
        return JsonResult.success(res);
    }
}